<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <p>子传父，数据放在子组件中，要传给父组件</p>
        <!-- 父组件监听子组件的自定义事件 -->
        <son1 @send="getMsg"></son1>
    </div>
    <template id="son1">
        <div>
            <p>我的数据：{{info1}}</p>
            <button @click="post">打电话</button>
        </div>
    </template>
    <script src="../vue.js"></script>
    <script>
        let vm = new Vue({
            el: '#app',
            data: {

            },
            methods: {
                getMsg(val1) {
                    console.log(111, val1);
                }
            },
            components: {
                son1: {
                    template: '#son1',
                    data() {
                        return {
                            info1: '打钱'
                        }
                    },
                    methods: {
                        post() {
                            // 发射自定义事件-第一个参数是自定义事件的名称必填的；后面的是传递的参数载荷，选填
                            this.$emit('send', [this.info1, 6666]);
                        }
                    }
                }
            }
        })
    </script>
</body>
</html>